package com.simple.elpmobile.onlinecase.ui.component;

import com.simple.elpmobile.onlinecase.ui.base.BaseContentPage;
import com.simple.elpmobile.onlinecase.ui.base.DragLayout;
import com.simple.elpmobile.onlinecase.ui.base.DragLayout.Status;

import android.content.Context;
import android.graphics.Color;
import android.os.Message;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;


public class MainPage extends BaseContentPage
{	
	private Context mContext ;
	private DragLayout mDragLayout;
	
	public MainPage(Context context) {
		this(context, null);
	}
	
	public MainPage(Context context, AttributeSet attrs){
		super(context, attrs);
		mContext = context;
		initView();
	}
	
	private void initView(){
		this.setBackgroundColor(Color.parseColor("#ffffff"));
		TextView tv = new TextView(mContext);
		tv.setText("MAIN");
		tv.setClickable(true);
		tv.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				mDragLayout.open();
				
			}
			
		});
		this.addView(tv);
	}
	

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (mDragLayout.getStatus() != Status.Close) {
            return true;
        }
        return super.onInterceptTouchEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mDragLayout.getStatus() != Status.Close) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
            	mDragLayout.close();
            }
            return true;
        }
        return super.onTouchEvent(event);
    }
	
	public void setDragLayout(DragLayout dl) {
	        this.mDragLayout = dl;
	}

	
	
	@Override
	public void onMessage(Message msg) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		
	} 

}